/**   
 * @Title: Vibrate.java 
 * @Package com.esun.util 
 * @Description: 震动效果
 * @Author: Miko baoz@500wan.com   
 * @Date: 2011-7-1 下午04:15:00  
 * Copyright (C) 2011 Shenzhen E-sun Sky Net Technology Co.,ltd.
 */
package com.esun.util;

import android.content.Context;
import android.os.Vibrator;

/** 
 * @ClassName: Vibrate 
 * @Description: 实现震动效果
 * @Author: Miko baoz@500wan.com
 * @Date: 2011-7-1 下午04:15:00 
 *  
 */
/**
 * 震动 如果报错请在 androidManifest.xml中加入 以下语句
 * 
 * <uses-permission android:name="android.permission.VIBRATE" />
 * 
 * @author alex.xin
 * 
 */
public class Vibrate {
	final static String TAG = "GameEngine";
	Vibrator vibrator;
	long[] pattern = {
						1,
						100,
						20,
						30 }; // 震动周期 可以自己设置

	public Vibrate(Context context) {
		vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
	}

	public void playVibrate(int type) {
		vibrator.vibrate(pattern, type);
		// -1不重复，非-1为从pattern的指定下标开始重复
	}

	public void Stop() {
		vibrator.cancel();
	}
}
